package omit.wage.controller;


import lombok.extern.slf4j.Slf4j;
import omit.wage.result.PageResult;
import omit.wage.result.Result;
import omit.wage.dto.*;
import omit.wage.service.IStaffService;
import omit.wage.service.IWageService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.naming.spi.DirStateFactory;
import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author author
 * @since 2024-06-11
 */
@RestController
@RequestMapping
@Slf4j
public class StaffController {

    //分页查询的接口
    @Autowired
    private IStaffService iStaffService;
    @GetMapping("/staff")
    public Result query(StaffPageDTO staffPageDTO){
        log.info("分页查询所有员工表的信息,参数为：{}", staffPageDTO);
        PageResult pageResult = iStaffService.pageQuery(staffPageDTO);
        return Result.success(pageResult);
    }
    //增加员工信息的接口
    @PostMapping("/staff")
    public Result insert(@RequestBody StaffModifyDTO staffModifyDTO){
        log.info("新增员工表的信息,参数为：{}", staffModifyDTO);
        iStaffService.insert(staffModifyDTO);
        return Result.success();
    }
    //修改员工信息的接口
    @PutMapping("/staff")
    public Result update(@RequestBody StaffChangeDTO staffChangeDTO){
        log.info("修改员工表的信息,参数为：{}", staffChangeDTO);
        iStaffService.update(staffChangeDTO);
        return Result.success();
    }
    //删除员工信息的接口
    @DeleteMapping("/staff/{ids}")
    public Result delete(@PathVariable List<Integer> ids){
        iStaffService.delete(ids);
        return Result.success();
    }
}





